<?php
	class cache
	{
		private $files; //this will be a list of all files currently in cache

		public function readCache($file)
		{
			return $this->files[$file];
			//read the file from the cache
			//initCache if not exist
		}

		public function loadCache($file,$redo=false)
		{
			//init the data from the file if not exist, read if exists
			//if redo is true reload if file already exists
			if ((!isset($this->files[$file]))||$redo)
			{
				initCache($file);
			}
		}

		public function checkHash($file,$strict=false)
		{
			//check the md5 hash
			//unload it if wrong
			//if scrict use the sha1 hash as well - I would like to use sha256 really but...
			$contents = file_get_contents($file);
			if (md5($contents)==md5($this->files[$file])) //test the md5 hash
			{
				if ((!$strict) || (sha1($contents)==sha1($this->files[$file]))) //test the sha1 hash
				{
					//they are equal @ sha1 or it is not scrict
				}
				else
				{
					//they are not equal in some regard
					$this->deinitCache($file);
				}
			}
		}
	
		public function checkAllHash()
		{
			//go thru every file in $files and check all hashes
		}
	
		
                private function initCache($file)
                {
                        //get file contents to the filelist
			if (file_exists($file) && is_readable($file))
			{
				$this->files[$file] = file_get_contents($file);
			}
                }

		private function deinitCache($file)
		{
			//remove file from list
		}
	}	

?>
